<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author:
// +----------------------------------------------------------------------
namespace Home\Controller;

use Think\Controller;
use Com\Wechat;
use Com\WechatAuth;

class MenuController extends Controller {
	public function index() {
		$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . appid . "&secret=" . appsecret;
		$output = https_request ( $url );
		$jsoninfo = json_decode ( $output, true );
	//	
		/*echo $jsoninfo ["access_token"];
		exit;*/
		$access_token = $jsoninfo ["access_token"];
		$jsonmenu = '{
		      "button":[
			      {
			            "name":"小型搬家",
				        "sub_button":[
			            {
			               "type":"view",
			               "name":"需要搬运",
			               "url":"http://nuower.com/index.php/Shows/demo"
			            },
						{
			               "type":"view",
			               "name":"不需要搬运",
						   "url":"http://nuower.com/index.php/Show/demo"
			            }]
			       },




			       {
						 "name":"专业搬家",
				        "sub_button":[
			            {
			               "type":"view",
			               "name":"家庭搬家",
			               "url":"http://nuower.com/index.php/Test/abc"
			            },
						{
			               "type":"view",
			               "name":"公司搬迁",
						   "url":"http://form.mikecrm.com/lFrDpt"
			            }]
			           /*"type":"view",
			           "name":"专业搬家",
					   "url":"http://nuower.com/index.php/Test/abc"*/
			        },
			        {
			            "name":"其他",
				        "sub_button":[
			            {
			               "type":"view",
			               "name":"社区",
						   "url":"http://nuower.com/index.php/Show/"
			            },
			            {
			               "type":"view",
			               "name":"我的订单",
			               "url":"http://nuower.com/index.php/Order/"
			            }]
			       	}
					
				]
		 }';
		
		$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token;
		$result = https_request ( $url, $jsonmenu );
		var_dump ( $result );
	}
}
